//
//  UIColor+GYColor.m
//  research
//
//  Created by 章鱼 on 17/3/27.
//  Copyright © 2017年 simon. All rights reserved.
//

#import "UIColor+GYColor.h"

#define HUUIColorFromRGB(rgbValue)    ([UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0])

@implementation UIColor (ORZColor)

+ (UIColor *)orz_mainColor {
    
    return [self colorWithHex:@"1b9cf6" alpha:1];
    
}

+ (UIColor *)orz_halfMainColor {
    
    return [self colorWithHex:@"00aded" alpha:.5f];
    
}

+ (UIColor *)orz_assistBlue {
    
    return [self colorWithHex:@"00c9ee" alpha:1];
    
}

+ (UIColor *)orz_assistIceBlue {
    
    return [self colorWithHex:@"eefaff" alpha:1];
    
}

+ (UIColor *)orz_assistGreen {
    
    return [self colorWithHex:@"1fc39e" alpha:1];
    
}

+ (UIColor *)orz_warningRed {
    
    return [self colorWithHex:@"f74c31" alpha:1];
    
}

+ (UIColor *)orz_assistYellow {
    
    return [self colorWithHex:@"d3aa1d" alpha:1];
    
}

+ (UIColor *)orz_assistLightYellow {
    
    return [self colorWithHex:@"faeab1" alpha:1];
    
}

#pragma mark textColor
+ (UIColor *)orz_textTitle {
    
    return [self colorWithHex:@"333333" alpha:1];
    
}

+ (UIColor *)orz_textSecondary {
    
    return [self colorWithHex:@"666666" alpha:1];
    
}

+ (UIColor *)orz_textAssist {
    
    return [self colorWithHex:@"999999" alpha:1];
    
}

+ (UIColor *)orz_textWhiteBackground {
    
    return [self colorWithHex:@"C7C7CD" alpha:1];
    
}

#pragma mark all

+ (UIColor *)orz_globalBackground {
    
    return [self colorWithHex:@"f5f5f5" alpha:1];
    
}

+ (UIColor *)orz_line {
    
    return [self colorWithHex:@"dddddd" alpha:1];
    
}

+ (UIColor *)orz_stroke {
    
    return [self colorWithHex:@"e0e0e0" alpha:1];
    
}

+ (UIColor *)orz_content {
    
    return [self colorWithHex:@"fafafa" alpha:1];
    
}
#pragma mark -
#pragma mark method
//16进制字符串 转换为int
+ (UIColor *)colorWithHex:(NSString *)hex alpha:(CGFloat)alpha
{
    //删除字符串中的空格
    NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    // String should be 6 or 8 characters
    if ([cString length] < 6)
    {
        return [UIColor clearColor];
    }
    // strip 0X if it appears
    //如果是0x开头的，那么截取字符串，字符串从索引为2的位置开始，一直到末尾
    if ([cString hasPrefix:@"0X"])
    {
        cString = [cString substringFromIndex:2];
    }
    //如果是#开头的，那么截取字符串，字符串从索引为1的位置开始，一直到末尾
    if ([cString hasPrefix:@"#"])
    {
        cString = [cString substringFromIndex:1];
    }
    if ([cString length] != 6)
    {
        return [UIColor clearColor];
    }
    // Separate into r, g, b substrings
    NSRange range;
    range.location = 0;
    range.length = 2;
    //r
    NSString *rString = [cString substringWithRange:range];
    //g
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    //b
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    // Scan values
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    return [UIColor colorWithRed:((float)r / 255.0f) green:((float)g / 255.0f) blue:((float)b / 255.0f) alpha:alpha];
}

@end
